<style lang="scss" scoped>
@import '../../styles/common/loading.less';
.container{
    border: none !important;
    margin-top: 4px;
}
.el-col-offset-1 {
    margin-left: 0%;
}
.button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

}
.col_a {
    margin-left: 2%;
}
.el-card {
    height: 200px;
}

.el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
}
.input-textarea{
    height: 87px !important
}
</style>
<template>
    <!-- 调查任务处理详情页面 -->
    <div class="common-background-color"
          v-loading="loading"
          element-loading-text="loading......"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)">
        <div style="width:98%;height:100%;margin: 6px 12px;">
            <el-collapse v-model="activeNames" >
                <el-collapse-item title="基本信息"  name="1">
                    <!-- 基本信息 -->
                    <template>
                        <el-form ref="prpLSurvey" :model="prpLSurvey" class="info-submit-form">
                            <el-row type="flex">
                                <el-col :span="8"  >
                                    <el-form-item label="大病赔案号">
                                        <el-input  v-model="prpLSurvey.caseNo"  disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" >
                                    <el-form-item label="保单号" >
                                        <el-input v-model="policyNo" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" >
                                    <el-form-item label="被保险人" >
                                        <el-input v-model="insuredName" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex">
                                <el-col :span="8" >
                                    <el-form-item label="社/医保号">
                                        <el-input v-model="socialSecurityNo" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" >
                                    <el-form-item label="证件类型">
                                        <el-input v-model="documentTypeName" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" >
                                    <el-form-item label="证件号">
                                        <el-input v-model="documentNo" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex">
                                <el-col :span="8"  >
                                    <el-form-item prop="surveyReason" label="调查原因"  >
                                        <el-input v-model="prpLSurvey.surveyReasonName" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" >
                                    <el-form-item label="原因描述">
                                        <el-input v-model="prpLSurvey.surveyDescribe" disabled placeholder="请输入原因描述"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="input-textarea">
                                <el-col :span="24">
                                    <el-form-item label="地点描述" prop="addressDesc">
                                        <el-input :rows="3" show-word-limit disabled v-model="prpLSurvey.addressDesc" type="textarea" placeholder="" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="input-textarea">
                                <el-col :span="24">
                                    <el-form-item label="经过" prop="surveyProcess">
                                        <el-input :rows="3" show-word-limit disabled  v-model="prpLSurvey.surveyProcess" type="textarea" placeholder=""></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="input-textarea">
                                <el-col :span="24">
                                    <el-form-item label="描述" prop="surveyRemark">
                                        <el-input :rows="3" show-word-limit disabled v-model="prpLSurvey.surveyRemark" type="textarea" placeholder="" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="input-textarea">
                                <el-col :span="24">
                                    <el-form-item label="结论" prop="surveyResult">
                                        <el-input :rows="3" show-word-limit disabled  v-model="prpLSurvey.surveyResult" type="textarea" placeholder="" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
                    </template>
                </el-collapse-item>
            </el-collapse>
            <el-collapse  v-model="activeNames" >
                <el-collapse-item title="调查历史轨迹信息"  name="2">
                    <!-- 调查轨迹信息 -->
                    <template>
                        <el-table
                            :data="researchHistory"
                            class="table"
                            ref="multipleTable"
                            header-cell-class-name="table-header"
                            style="margin: 5px 0;border: 1px solid #d6d9d8;"
                        >
                            <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
                            <el-table-column label="大病赔案号" align="center" width="165">
                                <template slot-scope="scope" >
                                    <a @click="applicant(scope.row)"  width="165" style="color: #1e99f9;cursor: pointer">{{ scope.row.caseNo }}</a>
                                </template>
                            </el-table-column>
                            <el-table-column prop="policyNo" label="保单号" align="center"></el-table-column>
                            <el-table-column prop="handlerCode" label="调查员工号" align="center"></el-table-column>
                            <el-table-column prop="handlerName" label="调查员姓名" align="center"></el-table-column>
                            <el-table-column prop="surveyReason" :formatter="formatSurveyReason" label="调查原因" align="center"></el-table-column>
                            <el-table-column prop="surveyResult" label="调查结论" align="center"></el-table-column>
                            <el-table-column prop="auditTime" label="调查时间" align="center"></el-table-column>
                        </el-table>
                    </template>
                </el-collapse-item>
            </el-collapse>
        </div>
        <div style="margin-top: 25px;text-align: center;height: 70px">
            <el-button type="primary" size="medium" style="width: 9%" @click="documentQueryShow">查看单证</el-button>
            <el-button type="primary" size="medium" style="width: 9%" @click="closePage" >关闭</el-button>
        </div>
    </div>
</template>
<script>
import {queryCaseSurveyDetail,querySurveyHistory,imgQueryShow} from '@/api/baseDate'
import Cookies from "js-cookie";
export default {
    name: 'surveyTaskAuditDetailCache',
    data() {
        return {
            loading: false,
            activeNames: ['1','2','3'],
            prpLSurvey:{
                surveyReasonName:''
            },
            id:'',
            taskState:'',
            policyNo:'', // 保单号
            insuredName:'', // 被保险人
            socialSecurityNo:'', // 社保号
            documentTypeName:'', // 证件类型
            documentNo:'', // 证件号
            comCode: '', // 归属机构
            researchHistory:[],
            bussNo:'',//单证查看需要的参数
        };
    },
    activated(){
        if(this.$route.params.taskId!=undefined){
            this.queryCaseSurveyTaskDetail();
            this.getQuerySurveyHistory();
        }
    },
    created() {
        this.queryCaseSurveyTaskDetail();
        this.getQuerySurveyHistory();
    },
    methods: {
        // 查看单证方法
        documentQueryShow(){
          this.bussNo= this.prpLSurvey.caseNo;
          if(this.bussNo !== null){
              imgQueryShow(this.bussNo).then(res => {
                  window.open(res.data.url)
              })
          }else{ 
              this.$message.error(`请您先检查大病赔案号后，再上传影像资料！`);
          }
        },
        // 调查审核详情
        queryCaseSurveyTaskDetail(){
            let taskId  = this.$route.params.taskId;
            this.id = taskId;
            this.taskState = this.$route.params.taskState;
            this.canEdit = false;
            if(this.taskState == '03' || this.taskState =='04' || this.taskState == '05'){
                this.canEdit = true;
            }
            const param = {
                id: this.id,
            }
            this.policyNo = this.$route.params.policyNo;
            this.insuredName = this.$route.params.insuredName;
            this.socialSecurityNo = this.$route.params.socialSecurityNo;
            this.documentTypeName = this.$route.params.documentTypeName;
            this.documentNo = this.$route.params.documentNo;
            queryCaseSurveyDetail(param) .then((res)=> {
                if(res){
                    if(res.data.resultCode){
                        if(res.data.resultCode != '0000'){ 
                            // 返回失败
                            this.$message.error(res.data.resultMsg);
                        }else{
                                this.prpLSurvey = res.data;
                                this.prpLClaimOpinionDTO = res.data.prpLClaimOpinionDTO;
                                if (this.prpLSurvey.surveyReason ==='1' ) {
                                    this.prpLSurvey.surveyReasonName = '频繁报销'
                                } else if (this.prpLSurvey.surveyReason === '2') {
                                    this.prpLSurvey.surveyReasonName = '异地就医'
                                } else if (this.prpLSurvey.surveyReason === '9') {
                                    this.prpLSurvey.surveyReasonName = '其它'
                                }
                        }
                    }else{
                        this.$message.error('系统异常'); 
                    }
                }else{
                  this.$message.error('系统异常'); 
                }
            })
        },
        // 调查历史轨迹
        getQuerySurveyHistory(){
            var data={
               documentNo: this.documentNo,
            }
            querySurveyHistory(data
            ).then(res => {
              this.researchHistory=res.data;
            })
        },
        applicant(row){
            this.form=row,
            this.$router.push({
            name: 'surveyTaskHistoryDetail',
            query: {
              form: JSON.stringify(this.form),
              prpLSurvey: JSON.stringify(this.prpLSurvey),
              item: JSON.stringify(this.item),
              its: JSON.stringify(1)
            }
          })
        },
        // 关闭当前页面
        closePage(){
            this.closePageTo(this.$store,this.$route,this.$router,'surveyTaskAudit');
        }
    }
}
</script>